{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "多辆车的路径规划 VRP:  \n",
    "- 条件：经过中国33个城市，一共4辆车，每辆车最大行驶10000公里  \n",
    "- 目标：使得每辆车的行驶里程数更接近  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-06T08:50:12.490007Z",
     "start_time": "2020-12-06T08:50:10.428889Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>北京</th>\n",
       "      <th>天津</th>\n",
       "      <th>哈尔滨</th>\n",
       "      <th>长春</th>\n",
       "      <th>沈阳</th>\n",
       "      <th>石家庄</th>\n",
       "      <th>呼和浩特</th>\n",
       "      <th>太原</th>\n",
       "      <th>上海</th>\n",
       "      <th>...</th>\n",
       "      <th>成都</th>\n",
       "      <th>重庆</th>\n",
       "      <th>南宁</th>\n",
       "      <th>贵阳</th>\n",
       "      <th>昆明</th>\n",
       "      <th>武汉</th>\n",
       "      <th>长沙</th>\n",
       "      <th>南昌</th>\n",
       "      <th>香港</th>\n",
       "      <th>澳门</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>北京</td>\n",
       "      <td>0</td>\n",
       "      <td>122476</td>\n",
       "      <td>1229869</td>\n",
       "      <td>987941</td>\n",
       "      <td>682963</td>\n",
       "      <td>294125</td>\n",
       "      <td>491658</td>\n",
       "      <td>487353</td>\n",
       "      <td>1210971</td>\n",
       "      <td>...</td>\n",
       "      <td>1835076</td>\n",
       "      <td>1753571</td>\n",
       "      <td>2346302</td>\n",
       "      <td>2086066</td>\n",
       "      <td>2587861</td>\n",
       "      <td>1161356</td>\n",
       "      <td>1477547</td>\n",
       "      <td>1431143</td>\n",
       "      <td>2203897</td>\n",
       "      <td>2273144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>天津</td>\n",
       "      <td>122476</td>\n",
       "      <td>0</td>\n",
       "      <td>1201742</td>\n",
       "      <td>959814</td>\n",
       "      <td>654836</td>\n",
       "      <td>314982</td>\n",
       "      <td>614846</td>\n",
       "      <td>508210</td>\n",
       "      <td>1093989</td>\n",
       "      <td>...</td>\n",
       "      <td>1855933</td>\n",
       "      <td>1774428</td>\n",
       "      <td>2343851</td>\n",
       "      <td>2083615</td>\n",
       "      <td>2585410</td>\n",
       "      <td>1158905</td>\n",
       "      <td>1475096</td>\n",
       "      <td>1358857</td>\n",
       "      <td>2201446</td>\n",
       "      <td>2270693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>哈尔滨</td>\n",
       "      <td>1229869</td>\n",
       "      <td>1201742</td>\n",
       "      <td>0</td>\n",
       "      <td>244488</td>\n",
       "      <td>551085</td>\n",
       "      <td>1493810</td>\n",
       "      <td>1684809</td>\n",
       "      <td>1687038</td>\n",
       "      <td>2269863</td>\n",
       "      <td>...</td>\n",
       "      <td>3034761</td>\n",
       "      <td>2953256</td>\n",
       "      <td>3533141</td>\n",
       "      <td>3272905</td>\n",
       "      <td>3774700</td>\n",
       "      <td>2348195</td>\n",
       "      <td>2664386</td>\n",
       "      <td>2534550</td>\n",
       "      <td>3390736</td>\n",
       "      <td>3459983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>长春</td>\n",
       "      <td>987941</td>\n",
       "      <td>959814</td>\n",
       "      <td>244488</td>\n",
       "      <td>0</td>\n",
       "      <td>310181</td>\n",
       "      <td>1252906</td>\n",
       "      <td>1431315</td>\n",
       "      <td>1446134</td>\n",
       "      <td>2028959</td>\n",
       "      <td>...</td>\n",
       "      <td>2793857</td>\n",
       "      <td>2712352</td>\n",
       "      <td>3292237</td>\n",
       "      <td>3032001</td>\n",
       "      <td>3533796</td>\n",
       "      <td>2107291</td>\n",
       "      <td>2423482</td>\n",
       "      <td>2293646</td>\n",
       "      <td>3149832</td>\n",
       "      <td>3219079</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>沈阳</td>\n",
       "      <td>682963</td>\n",
       "      <td>654836</td>\n",
       "      <td>551085</td>\n",
       "      <td>310181</td>\n",
       "      <td>0</td>\n",
       "      <td>950093</td>\n",
       "      <td>1171538</td>\n",
       "      <td>1143321</td>\n",
       "      <td>1726146</td>\n",
       "      <td>...</td>\n",
       "      <td>2491044</td>\n",
       "      <td>2409539</td>\n",
       "      <td>2989424</td>\n",
       "      <td>2729188</td>\n",
       "      <td>3230983</td>\n",
       "      <td>1804478</td>\n",
       "      <td>2120669</td>\n",
       "      <td>1990833</td>\n",
       "      <td>2847019</td>\n",
       "      <td>2916266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>石家庄</td>\n",
       "      <td>294125</td>\n",
       "      <td>314982</td>\n",
       "      <td>1493810</td>\n",
       "      <td>1252906</td>\n",
       "      <td>950093</td>\n",
       "      <td>0</td>\n",
       "      <td>594851</td>\n",
       "      <td>214615</td>\n",
       "      <td>1170170</td>\n",
       "      <td>...</td>\n",
       "      <td>1551896</td>\n",
       "      <td>1470391</td>\n",
       "      <td>2086876</td>\n",
       "      <td>1826211</td>\n",
       "      <td>2260044</td>\n",
       "      <td>909276</td>\n",
       "      <td>1218121</td>\n",
       "      <td>1243653</td>\n",
       "      <td>1974526</td>\n",
       "      <td>2013718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>呼和浩特</td>\n",
       "      <td>491658</td>\n",
       "      <td>614846</td>\n",
       "      <td>1684809</td>\n",
       "      <td>1431315</td>\n",
       "      <td>1171538</td>\n",
       "      <td>594851</td>\n",
       "      <td>0</td>\n",
       "      <td>443246</td>\n",
       "      <td>1703117</td>\n",
       "      <td>...</td>\n",
       "      <td>1728512</td>\n",
       "      <td>1664862</td>\n",
       "      <td>2529565</td>\n",
       "      <td>2046276</td>\n",
       "      <td>2436660</td>\n",
       "      <td>1393252</td>\n",
       "      <td>1681446</td>\n",
       "      <td>1738006</td>\n",
       "      <td>2458502</td>\n",
       "      <td>2463568</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>太原</td>\n",
       "      <td>487353</td>\n",
       "      <td>508210</td>\n",
       "      <td>1687038</td>\n",
       "      <td>1446134</td>\n",
       "      <td>1143321</td>\n",
       "      <td>214615</td>\n",
       "      <td>443246</td>\n",
       "      <td>0</td>\n",
       "      <td>1365196</td>\n",
       "      <td>...</td>\n",
       "      <td>1371477</td>\n",
       "      <td>1289972</td>\n",
       "      <td>2094228</td>\n",
       "      <td>1671386</td>\n",
       "      <td>2079625</td>\n",
       "      <td>957915</td>\n",
       "      <td>1246109</td>\n",
       "      <td>1302669</td>\n",
       "      <td>2023165</td>\n",
       "      <td>2028231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>上海</td>\n",
       "      <td>1210971</td>\n",
       "      <td>1093989</td>\n",
       "      <td>2269863</td>\n",
       "      <td>2028959</td>\n",
       "      <td>1726146</td>\n",
       "      <td>1170170</td>\n",
       "      <td>1703117</td>\n",
       "      <td>1365196</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1956341</td>\n",
       "      <td>1702128</td>\n",
       "      <td>1904381</td>\n",
       "      <td>1816148</td>\n",
       "      <td>2317943</td>\n",
       "      <td>835747</td>\n",
       "      <td>1081808</td>\n",
       "      <td>700706</td>\n",
       "      <td>1493623</td>\n",
       "      <td>1563775</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>杭州</td>\n",
       "      <td>1277042</td>\n",
       "      <td>1217026</td>\n",
       "      <td>2392900</td>\n",
       "      <td>2151996</td>\n",
       "      <td>1849183</td>\n",
       "      <td>1180721</td>\n",
       "      <td>1724699</td>\n",
       "      <td>1357544</td>\n",
       "      <td>179942</td>\n",
       "      <td>...</td>\n",
       "      <td>1885005</td>\n",
       "      <td>1621852</td>\n",
       "      <td>1720463</td>\n",
       "      <td>1669561</td>\n",
       "      <td>2183377</td>\n",
       "      <td>755471</td>\n",
       "      <td>889395</td>\n",
       "      <td>515972</td>\n",
       "      <td>1309705</td>\n",
       "      <td>1379857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>福州</td>\n",
       "      <td>1867253</td>\n",
       "      <td>1814186</td>\n",
       "      <td>2989879</td>\n",
       "      <td>2748975</td>\n",
       "      <td>2446162</td>\n",
       "      <td>1687844</td>\n",
       "      <td>2273946</td>\n",
       "      <td>1819081</td>\n",
       "      <td>766205</td>\n",
       "      <td>...</td>\n",
       "      <td>1994720</td>\n",
       "      <td>1743410</td>\n",
       "      <td>1444027</td>\n",
       "      <td>1567408</td>\n",
       "      <td>2082503</td>\n",
       "      <td>891724</td>\n",
       "      <td>845608</td>\n",
       "      <td>546197</td>\n",
       "      <td>848710</td>\n",
       "      <td>948348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>广州</td>\n",
       "      <td>2114801</td>\n",
       "      <td>2112350</td>\n",
       "      <td>3301640</td>\n",
       "      <td>3060736</td>\n",
       "      <td>2757923</td>\n",
       "      <td>1855375</td>\n",
       "      <td>2305225</td>\n",
       "      <td>1869888</td>\n",
       "      <td>1430436</td>\n",
       "      <td>...</td>\n",
       "      <td>1581801</td>\n",
       "      <td>1293041</td>\n",
       "      <td>566800</td>\n",
       "      <td>909989</td>\n",
       "      <td>1341800</td>\n",
       "      <td>963961</td>\n",
       "      <td>665817</td>\n",
       "      <td>783023</td>\n",
       "      <td>168978</td>\n",
       "      <td>160972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>海口</td>\n",
       "      <td>2627876</td>\n",
       "      <td>2625425</td>\n",
       "      <td>3814715</td>\n",
       "      <td>3573811</td>\n",
       "      <td>3270998</td>\n",
       "      <td>2368450</td>\n",
       "      <td>2811139</td>\n",
       "      <td>2375802</td>\n",
       "      <td>2031457</td>\n",
       "      <td>...</td>\n",
       "      <td>1700876</td>\n",
       "      <td>1405482</td>\n",
       "      <td>485498</td>\n",
       "      <td>1033615</td>\n",
       "      <td>1216344</td>\n",
       "      <td>1484027</td>\n",
       "      <td>1175712</td>\n",
       "      <td>1345540</td>\n",
       "      <td>700104</td>\n",
       "      <td>596171</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>合肥</td>\n",
       "      <td>1023736</td>\n",
       "      <td>956379</td>\n",
       "      <td>2132072</td>\n",
       "      <td>1891168</td>\n",
       "      <td>1588355</td>\n",
       "      <td>888447</td>\n",
       "      <td>1474549</td>\n",
       "      <td>1019684</td>\n",
       "      <td>460323</td>\n",
       "      <td>...</td>\n",
       "      <td>1512751</td>\n",
       "      <td>1244120</td>\n",
       "      <td>1599512</td>\n",
       "      <td>1438117</td>\n",
       "      <td>1939912</td>\n",
       "      <td>395042</td>\n",
       "      <td>730757</td>\n",
       "      <td>444491</td>\n",
       "      <td>1283593</td>\n",
       "      <td>1353745</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>郑州</td>\n",
       "      <td>690797</td>\n",
       "      <td>711654</td>\n",
       "      <td>1890482</td>\n",
       "      <td>1649578</td>\n",
       "      <td>1346765</td>\n",
       "      <td>423416</td>\n",
       "      <td>882350</td>\n",
       "      <td>447013</td>\n",
       "      <td>939925</td>\n",
       "      <td>...</td>\n",
       "      <td>1236106</td>\n",
       "      <td>1154601</td>\n",
       "      <td>1690310</td>\n",
       "      <td>1429645</td>\n",
       "      <td>1931440</td>\n",
       "      <td>512710</td>\n",
       "      <td>821555</td>\n",
       "      <td>857464</td>\n",
       "      <td>1577960</td>\n",
       "      <td>1617152</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>南京</td>\n",
       "      <td>1002497</td>\n",
       "      <td>935319</td>\n",
       "      <td>2111193</td>\n",
       "      <td>1870289</td>\n",
       "      <td>1567476</td>\n",
       "      <td>906176</td>\n",
       "      <td>1450154</td>\n",
       "      <td>1082999</td>\n",
       "      <td>300126</td>\n",
       "      <td>...</td>\n",
       "      <td>1665559</td>\n",
       "      <td>1396928</td>\n",
       "      <td>1751162</td>\n",
       "      <td>1590925</td>\n",
       "      <td>2092720</td>\n",
       "      <td>547850</td>\n",
       "      <td>882407</td>\n",
       "      <td>596693</td>\n",
       "      <td>1433969</td>\n",
       "      <td>1504121</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>济南</td>\n",
       "      <td>409437</td>\n",
       "      <td>342726</td>\n",
       "      <td>1518600</td>\n",
       "      <td>1277696</td>\n",
       "      <td>974883</td>\n",
       "      <td>334696</td>\n",
       "      <td>871374</td>\n",
       "      <td>535847</td>\n",
       "      <td>827062</td>\n",
       "      <td>...</td>\n",
       "      <td>1661261</td>\n",
       "      <td>1550091</td>\n",
       "      <td>2046442</td>\n",
       "      <td>1797508</td>\n",
       "      <td>2299303</td>\n",
       "      <td>858207</td>\n",
       "      <td>1177687</td>\n",
       "      <td>1064743</td>\n",
       "      <td>1900748</td>\n",
       "      <td>1973284</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>兰州</td>\n",
       "      <td>1436024</td>\n",
       "      <td>1483762</td>\n",
       "      <td>2634602</td>\n",
       "      <td>2393698</td>\n",
       "      <td>2090885</td>\n",
       "      <td>1198067</td>\n",
       "      <td>1122610</td>\n",
       "      <td>992238</td>\n",
       "      <td>1997565</td>\n",
       "      <td>...</td>\n",
       "      <td>975617</td>\n",
       "      <td>1087724</td>\n",
       "      <td>2017406</td>\n",
       "      <td>1481155</td>\n",
       "      <td>1790871</td>\n",
       "      <td>1367382</td>\n",
       "      <td>1627168</td>\n",
       "      <td>1727418</td>\n",
       "      <td>2404872</td>\n",
       "      <td>2409290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>银川</td>\n",
       "      <td>1193164</td>\n",
       "      <td>1146196</td>\n",
       "      <td>2386315</td>\n",
       "      <td>2132821</td>\n",
       "      <td>1753319</td>\n",
       "      <td>927565</td>\n",
       "      <td>714173</td>\n",
       "      <td>721736</td>\n",
       "      <td>1975560</td>\n",
       "      <td>...</td>\n",
       "      <td>1286130</td>\n",
       "      <td>1253297</td>\n",
       "      <td>2182979</td>\n",
       "      <td>1646728</td>\n",
       "      <td>1994278</td>\n",
       "      <td>1441833</td>\n",
       "      <td>1701619</td>\n",
       "      <td>1801869</td>\n",
       "      <td>2479323</td>\n",
       "      <td>2483741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>西宁</td>\n",
       "      <td>1193164</td>\n",
       "      <td>1146196</td>\n",
       "      <td>2386315</td>\n",
       "      <td>2132821</td>\n",
       "      <td>1753319</td>\n",
       "      <td>927565</td>\n",
       "      <td>714173</td>\n",
       "      <td>721736</td>\n",
       "      <td>1975560</td>\n",
       "      <td>...</td>\n",
       "      <td>1286130</td>\n",
       "      <td>1253297</td>\n",
       "      <td>2182979</td>\n",
       "      <td>1646728</td>\n",
       "      <td>1994278</td>\n",
       "      <td>1441833</td>\n",
       "      <td>1701619</td>\n",
       "      <td>1801869</td>\n",
       "      <td>2479323</td>\n",
       "      <td>2483741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>西安</td>\n",
       "      <td>1074438</td>\n",
       "      <td>1095295</td>\n",
       "      <td>2274123</td>\n",
       "      <td>2033219</td>\n",
       "      <td>1730406</td>\n",
       "      <td>791258</td>\n",
       "      <td>969574</td>\n",
       "      <td>610839</td>\n",
       "      <td>1371668</td>\n",
       "      <td>...</td>\n",
       "      <td>775889</td>\n",
       "      <td>690978</td>\n",
       "      <td>1608643</td>\n",
       "      <td>1072392</td>\n",
       "      <td>1484037</td>\n",
       "      <td>740806</td>\n",
       "      <td>1000592</td>\n",
       "      <td>1100842</td>\n",
       "      <td>1778296</td>\n",
       "      <td>1782714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>拉萨</td>\n",
       "      <td>3548859</td>\n",
       "      <td>3596597</td>\n",
       "      <td>4747437</td>\n",
       "      <td>4506533</td>\n",
       "      <td>4203720</td>\n",
       "      <td>3310902</td>\n",
       "      <td>3235445</td>\n",
       "      <td>3105073</td>\n",
       "      <td>4128003</td>\n",
       "      <td>...</td>\n",
       "      <td>1992559</td>\n",
       "      <td>2272211</td>\n",
       "      <td>2962662</td>\n",
       "      <td>2545739</td>\n",
       "      <td>2188273</td>\n",
       "      <td>3502041</td>\n",
       "      <td>3157022</td>\n",
       "      <td>3433608</td>\n",
       "      <td>3630295</td>\n",
       "      <td>3627977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>乌鲁木齐</td>\n",
       "      <td>2779905</td>\n",
       "      <td>2903093</td>\n",
       "      <td>3973056</td>\n",
       "      <td>3719562</td>\n",
       "      <td>3459785</td>\n",
       "      <td>2887289</td>\n",
       "      <td>2300914</td>\n",
       "      <td>2737040</td>\n",
       "      <td>3914510</td>\n",
       "      <td>...</td>\n",
       "      <td>2879752</td>\n",
       "      <td>2991859</td>\n",
       "      <td>3921541</td>\n",
       "      <td>3385290</td>\n",
       "      <td>3695006</td>\n",
       "      <td>3280138</td>\n",
       "      <td>3539924</td>\n",
       "      <td>3640174</td>\n",
       "      <td>4317628</td>\n",
       "      <td>4322046</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>成都</td>\n",
       "      <td>1835076</td>\n",
       "      <td>1855933</td>\n",
       "      <td>3034761</td>\n",
       "      <td>2793857</td>\n",
       "      <td>2491044</td>\n",
       "      <td>1551896</td>\n",
       "      <td>1728512</td>\n",
       "      <td>1371477</td>\n",
       "      <td>1956341</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>303312</td>\n",
       "      <td>1224927</td>\n",
       "      <td>660608</td>\n",
       "      <td>856259</td>\n",
       "      <td>1137121</td>\n",
       "      <td>1184770</td>\n",
       "      <td>1458130</td>\n",
       "      <td>1761599</td>\n",
       "      <td>1719942</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>重庆</td>\n",
       "      <td>1753571</td>\n",
       "      <td>1774428</td>\n",
       "      <td>2953256</td>\n",
       "      <td>2712352</td>\n",
       "      <td>2409539</td>\n",
       "      <td>1470391</td>\n",
       "      <td>1664862</td>\n",
       "      <td>1289972</td>\n",
       "      <td>1702128</td>\n",
       "      <td>...</td>\n",
       "      <td>303312</td>\n",
       "      <td>0</td>\n",
       "      <td>926597</td>\n",
       "      <td>383549</td>\n",
       "      <td>838042</td>\n",
       "      <td>904849</td>\n",
       "      <td>897207</td>\n",
       "      <td>1253616</td>\n",
       "      <td>1465624</td>\n",
       "      <td>1423967</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>南宁</td>\n",
       "      <td>2346302</td>\n",
       "      <td>2343851</td>\n",
       "      <td>3533141</td>\n",
       "      <td>3292237</td>\n",
       "      <td>2989424</td>\n",
       "      <td>2086876</td>\n",
       "      <td>2529565</td>\n",
       "      <td>2094228</td>\n",
       "      <td>1904381</td>\n",
       "      <td>...</td>\n",
       "      <td>1224927</td>\n",
       "      <td>926597</td>\n",
       "      <td>0</td>\n",
       "      <td>547054</td>\n",
       "      <td>775821</td>\n",
       "      <td>1192261</td>\n",
       "      <td>883946</td>\n",
       "      <td>1208103</td>\n",
       "      <td>758110</td>\n",
       "      <td>744929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>贵阳</td>\n",
       "      <td>2086066</td>\n",
       "      <td>2083615</td>\n",
       "      <td>3272905</td>\n",
       "      <td>3032001</td>\n",
       "      <td>2729188</td>\n",
       "      <td>1826211</td>\n",
       "      <td>2046276</td>\n",
       "      <td>1671386</td>\n",
       "      <td>1816148</td>\n",
       "      <td>...</td>\n",
       "      <td>660608</td>\n",
       "      <td>383549</td>\n",
       "      <td>547054</td>\n",
       "      <td>0</td>\n",
       "      <td>519303</td>\n",
       "      <td>1049418</td>\n",
       "      <td>807527</td>\n",
       "      <td>1160208</td>\n",
       "      <td>1083915</td>\n",
       "      <td>1042258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>昆明</td>\n",
       "      <td>2587861</td>\n",
       "      <td>2585410</td>\n",
       "      <td>3774700</td>\n",
       "      <td>3533796</td>\n",
       "      <td>3230983</td>\n",
       "      <td>2260044</td>\n",
       "      <td>2436660</td>\n",
       "      <td>2079625</td>\n",
       "      <td>2317943</td>\n",
       "      <td>...</td>\n",
       "      <td>856259</td>\n",
       "      <td>838042</td>\n",
       "      <td>775821</td>\n",
       "      <td>519303</td>\n",
       "      <td>0</td>\n",
       "      <td>1553480</td>\n",
       "      <td>1311589</td>\n",
       "      <td>1667998</td>\n",
       "      <td>1502196</td>\n",
       "      <td>1441495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>武汉</td>\n",
       "      <td>1161356</td>\n",
       "      <td>1158905</td>\n",
       "      <td>2348195</td>\n",
       "      <td>2107291</td>\n",
       "      <td>1804478</td>\n",
       "      <td>909276</td>\n",
       "      <td>1393252</td>\n",
       "      <td>957915</td>\n",
       "      <td>835747</td>\n",
       "      <td>...</td>\n",
       "      <td>1137121</td>\n",
       "      <td>904849</td>\n",
       "      <td>1192261</td>\n",
       "      <td>1049418</td>\n",
       "      <td>1553480</td>\n",
       "      <td>0</td>\n",
       "      <td>325491</td>\n",
       "      <td>355077</td>\n",
       "      <td>1081896</td>\n",
       "      <td>1121088</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>长沙</td>\n",
       "      <td>1477547</td>\n",
       "      <td>1475096</td>\n",
       "      <td>2664386</td>\n",
       "      <td>2423482</td>\n",
       "      <td>2120669</td>\n",
       "      <td>1218121</td>\n",
       "      <td>1681446</td>\n",
       "      <td>1246109</td>\n",
       "      <td>1081808</td>\n",
       "      <td>...</td>\n",
       "      <td>1184770</td>\n",
       "      <td>897207</td>\n",
       "      <td>883946</td>\n",
       "      <td>807527</td>\n",
       "      <td>1311589</td>\n",
       "      <td>325491</td>\n",
       "      <td>0</td>\n",
       "      <td>354217</td>\n",
       "      <td>817897</td>\n",
       "      <td>822315</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>南昌</td>\n",
       "      <td>1431143</td>\n",
       "      <td>1358857</td>\n",
       "      <td>2534550</td>\n",
       "      <td>2293646</td>\n",
       "      <td>1990833</td>\n",
       "      <td>1243653</td>\n",
       "      <td>1738006</td>\n",
       "      <td>1302669</td>\n",
       "      <td>700706</td>\n",
       "      <td>...</td>\n",
       "      <td>1458130</td>\n",
       "      <td>1253616</td>\n",
       "      <td>1208103</td>\n",
       "      <td>1160208</td>\n",
       "      <td>1667998</td>\n",
       "      <td>355077</td>\n",
       "      <td>354217</td>\n",
       "      <td>0</td>\n",
       "      <td>858848</td>\n",
       "      <td>929000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>香港</td>\n",
       "      <td>1431143</td>\n",
       "      <td>1358857</td>\n",
       "      <td>2534550</td>\n",
       "      <td>2293646</td>\n",
       "      <td>1990833</td>\n",
       "      <td>1243653</td>\n",
       "      <td>1738006</td>\n",
       "      <td>1302669</td>\n",
       "      <td>700706</td>\n",
       "      <td>...</td>\n",
       "      <td>1458130</td>\n",
       "      <td>1253616</td>\n",
       "      <td>1208103</td>\n",
       "      <td>1160208</td>\n",
       "      <td>1667998</td>\n",
       "      <td>355077</td>\n",
       "      <td>354217</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>929000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>澳门</td>\n",
       "      <td>2273144</td>\n",
       "      <td>2270693</td>\n",
       "      <td>3459983</td>\n",
       "      <td>3219079</td>\n",
       "      <td>2916266</td>\n",
       "      <td>2013718</td>\n",
       "      <td>2463568</td>\n",
       "      <td>2028231</td>\n",
       "      <td>1563775</td>\n",
       "      <td>...</td>\n",
       "      <td>1719942</td>\n",
       "      <td>1423967</td>\n",
       "      <td>744929</td>\n",
       "      <td>1042258</td>\n",
       "      <td>1441495</td>\n",
       "      <td>1121088</td>\n",
       "      <td>822315</td>\n",
       "      <td>929000</td>\n",
       "      <td>929000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>33 rows × 34 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0       北京       天津      哈尔滨       长春       沈阳      石家庄     呼和浩特  \\\n",
       "0          北京        0   122476  1229869   987941   682963   294125   491658   \n",
       "1          天津   122476        0  1201742   959814   654836   314982   614846   \n",
       "2         哈尔滨  1229869  1201742        0   244488   551085  1493810  1684809   \n",
       "3          长春   987941   959814   244488        0   310181  1252906  1431315   \n",
       "4          沈阳   682963   654836   551085   310181        0   950093  1171538   \n",
       "5         石家庄   294125   314982  1493810  1252906   950093        0   594851   \n",
       "6        呼和浩特   491658   614846  1684809  1431315  1171538   594851        0   \n",
       "7          太原   487353   508210  1687038  1446134  1143321   214615   443246   \n",
       "8          上海  1210971  1093989  2269863  2028959  1726146  1170170  1703117   \n",
       "9          杭州  1277042  1217026  2392900  2151996  1849183  1180721  1724699   \n",
       "10         福州  1867253  1814186  2989879  2748975  2446162  1687844  2273946   \n",
       "11         广州  2114801  2112350  3301640  3060736  2757923  1855375  2305225   \n",
       "12         海口  2627876  2625425  3814715  3573811  3270998  2368450  2811139   \n",
       "13         合肥  1023736   956379  2132072  1891168  1588355   888447  1474549   \n",
       "14         郑州   690797   711654  1890482  1649578  1346765   423416   882350   \n",
       "15         南京  1002497   935319  2111193  1870289  1567476   906176  1450154   \n",
       "16         济南   409437   342726  1518600  1277696   974883   334696   871374   \n",
       "17         兰州  1436024  1483762  2634602  2393698  2090885  1198067  1122610   \n",
       "18         银川  1193164  1146196  2386315  2132821  1753319   927565   714173   \n",
       "19         西宁  1193164  1146196  2386315  2132821  1753319   927565   714173   \n",
       "20         西安  1074438  1095295  2274123  2033219  1730406   791258   969574   \n",
       "21         拉萨  3548859  3596597  4747437  4506533  4203720  3310902  3235445   \n",
       "22       乌鲁木齐  2779905  2903093  3973056  3719562  3459785  2887289  2300914   \n",
       "23         成都  1835076  1855933  3034761  2793857  2491044  1551896  1728512   \n",
       "24         重庆  1753571  1774428  2953256  2712352  2409539  1470391  1664862   \n",
       "25         南宁  2346302  2343851  3533141  3292237  2989424  2086876  2529565   \n",
       "26         贵阳  2086066  2083615  3272905  3032001  2729188  1826211  2046276   \n",
       "27         昆明  2587861  2585410  3774700  3533796  3230983  2260044  2436660   \n",
       "28         武汉  1161356  1158905  2348195  2107291  1804478   909276  1393252   \n",
       "29         长沙  1477547  1475096  2664386  2423482  2120669  1218121  1681446   \n",
       "30         南昌  1431143  1358857  2534550  2293646  1990833  1243653  1738006   \n",
       "31         香港  1431143  1358857  2534550  2293646  1990833  1243653  1738006   \n",
       "32         澳门  2273144  2270693  3459983  3219079  2916266  2013718  2463568   \n",
       "\n",
       "         太原       上海  ...       成都       重庆       南宁       贵阳       昆明  \\\n",
       "0    487353  1210971  ...  1835076  1753571  2346302  2086066  2587861   \n",
       "1    508210  1093989  ...  1855933  1774428  2343851  2083615  2585410   \n",
       "2   1687038  2269863  ...  3034761  2953256  3533141  3272905  3774700   \n",
       "3   1446134  2028959  ...  2793857  2712352  3292237  3032001  3533796   \n",
       "4   1143321  1726146  ...  2491044  2409539  2989424  2729188  3230983   \n",
       "5    214615  1170170  ...  1551896  1470391  2086876  1826211  2260044   \n",
       "6    443246  1703117  ...  1728512  1664862  2529565  2046276  2436660   \n",
       "7         0  1365196  ...  1371477  1289972  2094228  1671386  2079625   \n",
       "8   1365196        0  ...  1956341  1702128  1904381  1816148  2317943   \n",
       "9   1357544   179942  ...  1885005  1621852  1720463  1669561  2183377   \n",
       "10  1819081   766205  ...  1994720  1743410  1444027  1567408  2082503   \n",
       "11  1869888  1430436  ...  1581801  1293041   566800   909989  1341800   \n",
       "12  2375802  2031457  ...  1700876  1405482   485498  1033615  1216344   \n",
       "13  1019684   460323  ...  1512751  1244120  1599512  1438117  1939912   \n",
       "14   447013   939925  ...  1236106  1154601  1690310  1429645  1931440   \n",
       "15  1082999   300126  ...  1665559  1396928  1751162  1590925  2092720   \n",
       "16   535847   827062  ...  1661261  1550091  2046442  1797508  2299303   \n",
       "17   992238  1997565  ...   975617  1087724  2017406  1481155  1790871   \n",
       "18   721736  1975560  ...  1286130  1253297  2182979  1646728  1994278   \n",
       "19   721736  1975560  ...  1286130  1253297  2182979  1646728  1994278   \n",
       "20   610839  1371668  ...   775889   690978  1608643  1072392  1484037   \n",
       "21  3105073  4128003  ...  1992559  2272211  2962662  2545739  2188273   \n",
       "22  2737040  3914510  ...  2879752  2991859  3921541  3385290  3695006   \n",
       "23  1371477  1956341  ...        0   303312  1224927   660608   856259   \n",
       "24  1289972  1702128  ...   303312        0   926597   383549   838042   \n",
       "25  2094228  1904381  ...  1224927   926597        0   547054   775821   \n",
       "26  1671386  1816148  ...   660608   383549   547054        0   519303   \n",
       "27  2079625  2317943  ...   856259   838042   775821   519303        0   \n",
       "28   957915   835747  ...  1137121   904849  1192261  1049418  1553480   \n",
       "29  1246109  1081808  ...  1184770   897207   883946   807527  1311589   \n",
       "30  1302669   700706  ...  1458130  1253616  1208103  1160208  1667998   \n",
       "31  1302669   700706  ...  1458130  1253616  1208103  1160208  1667998   \n",
       "32  2028231  1563775  ...  1719942  1423967   744929  1042258  1441495   \n",
       "\n",
       "         武汉       长沙       南昌       香港       澳门  \n",
       "0   1161356  1477547  1431143  2203897  2273144  \n",
       "1   1158905  1475096  1358857  2201446  2270693  \n",
       "2   2348195  2664386  2534550  3390736  3459983  \n",
       "3   2107291  2423482  2293646  3149832  3219079  \n",
       "4   1804478  2120669  1990833  2847019  2916266  \n",
       "5    909276  1218121  1243653  1974526  2013718  \n",
       "6   1393252  1681446  1738006  2458502  2463568  \n",
       "7    957915  1246109  1302669  2023165  2028231  \n",
       "8    835747  1081808   700706  1493623  1563775  \n",
       "9    755471   889395   515972  1309705  1379857  \n",
       "10   891724   845608   546197   848710   948348  \n",
       "11   963961   665817   783023   168978   160972  \n",
       "12  1484027  1175712  1345540   700104   596171  \n",
       "13   395042   730757   444491  1283593  1353745  \n",
       "14   512710   821555   857464  1577960  1617152  \n",
       "15   547850   882407   596693  1433969  1504121  \n",
       "16   858207  1177687  1064743  1900748  1973284  \n",
       "17  1367382  1627168  1727418  2404872  2409290  \n",
       "18  1441833  1701619  1801869  2479323  2483741  \n",
       "19  1441833  1701619  1801869  2479323  2483741  \n",
       "20   740806  1000592  1100842  1778296  1782714  \n",
       "21  3502041  3157022  3433608  3630295  3627977  \n",
       "22  3280138  3539924  3640174  4317628  4322046  \n",
       "23  1137121  1184770  1458130  1761599  1719942  \n",
       "24   904849   897207  1253616  1465624  1423967  \n",
       "25  1192261   883946  1208103   758110   744929  \n",
       "26  1049418   807527  1160208  1083915  1042258  \n",
       "27  1553480  1311589  1667998  1502196  1441495  \n",
       "28        0   325491   355077  1081896  1121088  \n",
       "29   325491        0   354217   817897   822315  \n",
       "30   355077   354217        0   858848   929000  \n",
       "31   355077   354217        1        0   929000  \n",
       "32  1121088   822315   929000   929000        0  \n",
       "\n",
       "[33 rows x 34 columns]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "data = pd.read_excel('./distance.xlsx')\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-06T08:50:12.565011Z",
     "start_time": "2020-12-06T08:50:12.494007Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>北京</th>\n",
       "      <th>天津</th>\n",
       "      <th>哈尔滨</th>\n",
       "      <th>长春</th>\n",
       "      <th>沈阳</th>\n",
       "      <th>石家庄</th>\n",
       "      <th>呼和浩特</th>\n",
       "      <th>太原</th>\n",
       "      <th>上海</th>\n",
       "      <th>杭州</th>\n",
       "      <th>...</th>\n",
       "      <th>成都</th>\n",
       "      <th>重庆</th>\n",
       "      <th>南宁</th>\n",
       "      <th>贵阳</th>\n",
       "      <th>昆明</th>\n",
       "      <th>武汉</th>\n",
       "      <th>长沙</th>\n",
       "      <th>南昌</th>\n",
       "      <th>香港</th>\n",
       "      <th>澳门</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>122476</td>\n",
       "      <td>1229869</td>\n",
       "      <td>987941</td>\n",
       "      <td>682963</td>\n",
       "      <td>294125</td>\n",
       "      <td>491658</td>\n",
       "      <td>487353</td>\n",
       "      <td>1210971</td>\n",
       "      <td>1277042</td>\n",
       "      <td>...</td>\n",
       "      <td>1835076</td>\n",
       "      <td>1753571</td>\n",
       "      <td>2346302</td>\n",
       "      <td>2086066</td>\n",
       "      <td>2587861</td>\n",
       "      <td>1161356</td>\n",
       "      <td>1477547</td>\n",
       "      <td>1431143</td>\n",
       "      <td>2203897</td>\n",
       "      <td>2273144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>122476</td>\n",
       "      <td>0</td>\n",
       "      <td>1201742</td>\n",
       "      <td>959814</td>\n",
       "      <td>654836</td>\n",
       "      <td>314982</td>\n",
       "      <td>614846</td>\n",
       "      <td>508210</td>\n",
       "      <td>1093989</td>\n",
       "      <td>1217026</td>\n",
       "      <td>...</td>\n",
       "      <td>1855933</td>\n",
       "      <td>1774428</td>\n",
       "      <td>2343851</td>\n",
       "      <td>2083615</td>\n",
       "      <td>2585410</td>\n",
       "      <td>1158905</td>\n",
       "      <td>1475096</td>\n",
       "      <td>1358857</td>\n",
       "      <td>2201446</td>\n",
       "      <td>2270693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1229869</td>\n",
       "      <td>1201742</td>\n",
       "      <td>0</td>\n",
       "      <td>244488</td>\n",
       "      <td>551085</td>\n",
       "      <td>1493810</td>\n",
       "      <td>1684809</td>\n",
       "      <td>1687038</td>\n",
       "      <td>2269863</td>\n",
       "      <td>2392900</td>\n",
       "      <td>...</td>\n",
       "      <td>3034761</td>\n",
       "      <td>2953256</td>\n",
       "      <td>3533141</td>\n",
       "      <td>3272905</td>\n",
       "      <td>3774700</td>\n",
       "      <td>2348195</td>\n",
       "      <td>2664386</td>\n",
       "      <td>2534550</td>\n",
       "      <td>3390736</td>\n",
       "      <td>3459983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>987941</td>\n",
       "      <td>959814</td>\n",
       "      <td>244488</td>\n",
       "      <td>0</td>\n",
       "      <td>310181</td>\n",
       "      <td>1252906</td>\n",
       "      <td>1431315</td>\n",
       "      <td>1446134</td>\n",
       "      <td>2028959</td>\n",
       "      <td>2151996</td>\n",
       "      <td>...</td>\n",
       "      <td>2793857</td>\n",
       "      <td>2712352</td>\n",
       "      <td>3292237</td>\n",
       "      <td>3032001</td>\n",
       "      <td>3533796</td>\n",
       "      <td>2107291</td>\n",
       "      <td>2423482</td>\n",
       "      <td>2293646</td>\n",
       "      <td>3149832</td>\n",
       "      <td>3219079</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>682963</td>\n",
       "      <td>654836</td>\n",
       "      <td>551085</td>\n",
       "      <td>310181</td>\n",
       "      <td>0</td>\n",
       "      <td>950093</td>\n",
       "      <td>1171538</td>\n",
       "      <td>1143321</td>\n",
       "      <td>1726146</td>\n",
       "      <td>1849183</td>\n",
       "      <td>...</td>\n",
       "      <td>2491044</td>\n",
       "      <td>2409539</td>\n",
       "      <td>2989424</td>\n",
       "      <td>2729188</td>\n",
       "      <td>3230983</td>\n",
       "      <td>1804478</td>\n",
       "      <td>2120669</td>\n",
       "      <td>1990833</td>\n",
       "      <td>2847019</td>\n",
       "      <td>2916266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>294125</td>\n",
       "      <td>314982</td>\n",
       "      <td>1493810</td>\n",
       "      <td>1252906</td>\n",
       "      <td>950093</td>\n",
       "      <td>0</td>\n",
       "      <td>594851</td>\n",
       "      <td>214615</td>\n",
       "      <td>1170170</td>\n",
       "      <td>1180721</td>\n",
       "      <td>...</td>\n",
       "      <td>1551896</td>\n",
       "      <td>1470391</td>\n",
       "      <td>2086876</td>\n",
       "      <td>1826211</td>\n",
       "      <td>2260044</td>\n",
       "      <td>909276</td>\n",
       "      <td>1218121</td>\n",
       "      <td>1243653</td>\n",
       "      <td>1974526</td>\n",
       "      <td>2013718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>491658</td>\n",
       "      <td>614846</td>\n",
       "      <td>1684809</td>\n",
       "      <td>1431315</td>\n",
       "      <td>1171538</td>\n",
       "      <td>594851</td>\n",
       "      <td>0</td>\n",
       "      <td>443246</td>\n",
       "      <td>1703117</td>\n",
       "      <td>1724699</td>\n",
       "      <td>...</td>\n",
       "      <td>1728512</td>\n",
       "      <td>1664862</td>\n",
       "      <td>2529565</td>\n",
       "      <td>2046276</td>\n",
       "      <td>2436660</td>\n",
       "      <td>1393252</td>\n",
       "      <td>1681446</td>\n",
       "      <td>1738006</td>\n",
       "      <td>2458502</td>\n",
       "      <td>2463568</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>487353</td>\n",
       "      <td>508210</td>\n",
       "      <td>1687038</td>\n",
       "      <td>1446134</td>\n",
       "      <td>1143321</td>\n",
       "      <td>214615</td>\n",
       "      <td>443246</td>\n",
       "      <td>0</td>\n",
       "      <td>1365196</td>\n",
       "      <td>1357544</td>\n",
       "      <td>...</td>\n",
       "      <td>1371477</td>\n",
       "      <td>1289972</td>\n",
       "      <td>2094228</td>\n",
       "      <td>1671386</td>\n",
       "      <td>2079625</td>\n",
       "      <td>957915</td>\n",
       "      <td>1246109</td>\n",
       "      <td>1302669</td>\n",
       "      <td>2023165</td>\n",
       "      <td>2028231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1210971</td>\n",
       "      <td>1093989</td>\n",
       "      <td>2269863</td>\n",
       "      <td>2028959</td>\n",
       "      <td>1726146</td>\n",
       "      <td>1170170</td>\n",
       "      <td>1703117</td>\n",
       "      <td>1365196</td>\n",
       "      <td>0</td>\n",
       "      <td>179942</td>\n",
       "      <td>...</td>\n",
       "      <td>1956341</td>\n",
       "      <td>1702128</td>\n",
       "      <td>1904381</td>\n",
       "      <td>1816148</td>\n",
       "      <td>2317943</td>\n",
       "      <td>835747</td>\n",
       "      <td>1081808</td>\n",
       "      <td>700706</td>\n",
       "      <td>1493623</td>\n",
       "      <td>1563775</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1277042</td>\n",
       "      <td>1217026</td>\n",
       "      <td>2392900</td>\n",
       "      <td>2151996</td>\n",
       "      <td>1849183</td>\n",
       "      <td>1180721</td>\n",
       "      <td>1724699</td>\n",
       "      <td>1357544</td>\n",
       "      <td>179942</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1885005</td>\n",
       "      <td>1621852</td>\n",
       "      <td>1720463</td>\n",
       "      <td>1669561</td>\n",
       "      <td>2183377</td>\n",
       "      <td>755471</td>\n",
       "      <td>889395</td>\n",
       "      <td>515972</td>\n",
       "      <td>1309705</td>\n",
       "      <td>1379857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1867253</td>\n",
       "      <td>1814186</td>\n",
       "      <td>2989879</td>\n",
       "      <td>2748975</td>\n",
       "      <td>2446162</td>\n",
       "      <td>1687844</td>\n",
       "      <td>2273946</td>\n",
       "      <td>1819081</td>\n",
       "      <td>766205</td>\n",
       "      <td>623237</td>\n",
       "      <td>...</td>\n",
       "      <td>1994720</td>\n",
       "      <td>1743410</td>\n",
       "      <td>1444027</td>\n",
       "      <td>1567408</td>\n",
       "      <td>2082503</td>\n",
       "      <td>891724</td>\n",
       "      <td>845608</td>\n",
       "      <td>546197</td>\n",
       "      <td>848710</td>\n",
       "      <td>948348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2114801</td>\n",
       "      <td>2112350</td>\n",
       "      <td>3301640</td>\n",
       "      <td>3060736</td>\n",
       "      <td>2757923</td>\n",
       "      <td>1855375</td>\n",
       "      <td>2305225</td>\n",
       "      <td>1869888</td>\n",
       "      <td>1430436</td>\n",
       "      <td>1246518</td>\n",
       "      <td>...</td>\n",
       "      <td>1581801</td>\n",
       "      <td>1293041</td>\n",
       "      <td>566800</td>\n",
       "      <td>909989</td>\n",
       "      <td>1341800</td>\n",
       "      <td>963961</td>\n",
       "      <td>665817</td>\n",
       "      <td>783023</td>\n",
       "      <td>168978</td>\n",
       "      <td>160972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2627876</td>\n",
       "      <td>2625425</td>\n",
       "      <td>3814715</td>\n",
       "      <td>3573811</td>\n",
       "      <td>3270998</td>\n",
       "      <td>2368450</td>\n",
       "      <td>2811139</td>\n",
       "      <td>2375802</td>\n",
       "      <td>2031457</td>\n",
       "      <td>1847539</td>\n",
       "      <td>...</td>\n",
       "      <td>1700876</td>\n",
       "      <td>1405482</td>\n",
       "      <td>485498</td>\n",
       "      <td>1033615</td>\n",
       "      <td>1216344</td>\n",
       "      <td>1484027</td>\n",
       "      <td>1175712</td>\n",
       "      <td>1345540</td>\n",
       "      <td>700104</td>\n",
       "      <td>596171</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1023736</td>\n",
       "      <td>956379</td>\n",
       "      <td>2132072</td>\n",
       "      <td>1891168</td>\n",
       "      <td>1588355</td>\n",
       "      <td>888447</td>\n",
       "      <td>1474549</td>\n",
       "      <td>1019684</td>\n",
       "      <td>460323</td>\n",
       "      <td>407754</td>\n",
       "      <td>...</td>\n",
       "      <td>1512751</td>\n",
       "      <td>1244120</td>\n",
       "      <td>1599512</td>\n",
       "      <td>1438117</td>\n",
       "      <td>1939912</td>\n",
       "      <td>395042</td>\n",
       "      <td>730757</td>\n",
       "      <td>444491</td>\n",
       "      <td>1283593</td>\n",
       "      <td>1353745</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>690797</td>\n",
       "      <td>711654</td>\n",
       "      <td>1890482</td>\n",
       "      <td>1649578</td>\n",
       "      <td>1346765</td>\n",
       "      <td>423416</td>\n",
       "      <td>882350</td>\n",
       "      <td>447013</td>\n",
       "      <td>939925</td>\n",
       "      <td>927970</td>\n",
       "      <td>...</td>\n",
       "      <td>1236106</td>\n",
       "      <td>1154601</td>\n",
       "      <td>1690310</td>\n",
       "      <td>1429645</td>\n",
       "      <td>1931440</td>\n",
       "      <td>512710</td>\n",
       "      <td>821555</td>\n",
       "      <td>857464</td>\n",
       "      <td>1577960</td>\n",
       "      <td>1617152</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1002497</td>\n",
       "      <td>935319</td>\n",
       "      <td>2111193</td>\n",
       "      <td>1870289</td>\n",
       "      <td>1567476</td>\n",
       "      <td>906176</td>\n",
       "      <td>1450154</td>\n",
       "      <td>1082999</td>\n",
       "      <td>300126</td>\n",
       "      <td>281354</td>\n",
       "      <td>...</td>\n",
       "      <td>1665559</td>\n",
       "      <td>1396928</td>\n",
       "      <td>1751162</td>\n",
       "      <td>1590925</td>\n",
       "      <td>2092720</td>\n",
       "      <td>547850</td>\n",
       "      <td>882407</td>\n",
       "      <td>596693</td>\n",
       "      <td>1433969</td>\n",
       "      <td>1504121</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>409437</td>\n",
       "      <td>342726</td>\n",
       "      <td>1518600</td>\n",
       "      <td>1277696</td>\n",
       "      <td>974883</td>\n",
       "      <td>334696</td>\n",
       "      <td>871374</td>\n",
       "      <td>535847</td>\n",
       "      <td>827062</td>\n",
       "      <td>877380</td>\n",
       "      <td>...</td>\n",
       "      <td>1661261</td>\n",
       "      <td>1550091</td>\n",
       "      <td>2046442</td>\n",
       "      <td>1797508</td>\n",
       "      <td>2299303</td>\n",
       "      <td>858207</td>\n",
       "      <td>1177687</td>\n",
       "      <td>1064743</td>\n",
       "      <td>1900748</td>\n",
       "      <td>1973284</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1436024</td>\n",
       "      <td>1483762</td>\n",
       "      <td>2634602</td>\n",
       "      <td>2393698</td>\n",
       "      <td>2090885</td>\n",
       "      <td>1198067</td>\n",
       "      <td>1122610</td>\n",
       "      <td>992238</td>\n",
       "      <td>1997565</td>\n",
       "      <td>1944996</td>\n",
       "      <td>...</td>\n",
       "      <td>975617</td>\n",
       "      <td>1087724</td>\n",
       "      <td>2017406</td>\n",
       "      <td>1481155</td>\n",
       "      <td>1790871</td>\n",
       "      <td>1367382</td>\n",
       "      <td>1627168</td>\n",
       "      <td>1727418</td>\n",
       "      <td>2404872</td>\n",
       "      <td>2409290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1193164</td>\n",
       "      <td>1146196</td>\n",
       "      <td>2386315</td>\n",
       "      <td>2132821</td>\n",
       "      <td>1753319</td>\n",
       "      <td>927565</td>\n",
       "      <td>714173</td>\n",
       "      <td>721736</td>\n",
       "      <td>1975560</td>\n",
       "      <td>1957012</td>\n",
       "      <td>...</td>\n",
       "      <td>1286130</td>\n",
       "      <td>1253297</td>\n",
       "      <td>2182979</td>\n",
       "      <td>1646728</td>\n",
       "      <td>1994278</td>\n",
       "      <td>1441833</td>\n",
       "      <td>1701619</td>\n",
       "      <td>1801869</td>\n",
       "      <td>2479323</td>\n",
       "      <td>2483741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1193164</td>\n",
       "      <td>1146196</td>\n",
       "      <td>2386315</td>\n",
       "      <td>2132821</td>\n",
       "      <td>1753319</td>\n",
       "      <td>927565</td>\n",
       "      <td>714173</td>\n",
       "      <td>721736</td>\n",
       "      <td>1975560</td>\n",
       "      <td>1957012</td>\n",
       "      <td>...</td>\n",
       "      <td>1286130</td>\n",
       "      <td>1253297</td>\n",
       "      <td>2182979</td>\n",
       "      <td>1646728</td>\n",
       "      <td>1994278</td>\n",
       "      <td>1441833</td>\n",
       "      <td>1701619</td>\n",
       "      <td>1801869</td>\n",
       "      <td>2479323</td>\n",
       "      <td>2483741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1074438</td>\n",
       "      <td>1095295</td>\n",
       "      <td>2274123</td>\n",
       "      <td>2033219</td>\n",
       "      <td>1730406</td>\n",
       "      <td>791258</td>\n",
       "      <td>969574</td>\n",
       "      <td>610839</td>\n",
       "      <td>1371668</td>\n",
       "      <td>1319099</td>\n",
       "      <td>...</td>\n",
       "      <td>775889</td>\n",
       "      <td>690978</td>\n",
       "      <td>1608643</td>\n",
       "      <td>1072392</td>\n",
       "      <td>1484037</td>\n",
       "      <td>740806</td>\n",
       "      <td>1000592</td>\n",
       "      <td>1100842</td>\n",
       "      <td>1778296</td>\n",
       "      <td>1782714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>3548859</td>\n",
       "      <td>3596597</td>\n",
       "      <td>4747437</td>\n",
       "      <td>4506533</td>\n",
       "      <td>4203720</td>\n",
       "      <td>3310902</td>\n",
       "      <td>3235445</td>\n",
       "      <td>3105073</td>\n",
       "      <td>4128003</td>\n",
       "      <td>4075434</td>\n",
       "      <td>...</td>\n",
       "      <td>1992559</td>\n",
       "      <td>2272211</td>\n",
       "      <td>2962662</td>\n",
       "      <td>2545739</td>\n",
       "      <td>2188273</td>\n",
       "      <td>3502041</td>\n",
       "      <td>3157022</td>\n",
       "      <td>3433608</td>\n",
       "      <td>3630295</td>\n",
       "      <td>3627977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2779905</td>\n",
       "      <td>2903093</td>\n",
       "      <td>3973056</td>\n",
       "      <td>3719562</td>\n",
       "      <td>3459785</td>\n",
       "      <td>2887289</td>\n",
       "      <td>2300914</td>\n",
       "      <td>2737040</td>\n",
       "      <td>3914510</td>\n",
       "      <td>3861941</td>\n",
       "      <td>...</td>\n",
       "      <td>2879752</td>\n",
       "      <td>2991859</td>\n",
       "      <td>3921541</td>\n",
       "      <td>3385290</td>\n",
       "      <td>3695006</td>\n",
       "      <td>3280138</td>\n",
       "      <td>3539924</td>\n",
       "      <td>3640174</td>\n",
       "      <td>4317628</td>\n",
       "      <td>4322046</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1835076</td>\n",
       "      <td>1855933</td>\n",
       "      <td>3034761</td>\n",
       "      <td>2793857</td>\n",
       "      <td>2491044</td>\n",
       "      <td>1551896</td>\n",
       "      <td>1728512</td>\n",
       "      <td>1371477</td>\n",
       "      <td>1956341</td>\n",
       "      <td>1885005</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>303312</td>\n",
       "      <td>1224927</td>\n",
       "      <td>660608</td>\n",
       "      <td>856259</td>\n",
       "      <td>1137121</td>\n",
       "      <td>1184770</td>\n",
       "      <td>1458130</td>\n",
       "      <td>1761599</td>\n",
       "      <td>1719942</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1753571</td>\n",
       "      <td>1774428</td>\n",
       "      <td>2953256</td>\n",
       "      <td>2712352</td>\n",
       "      <td>2409539</td>\n",
       "      <td>1470391</td>\n",
       "      <td>1664862</td>\n",
       "      <td>1289972</td>\n",
       "      <td>1702128</td>\n",
       "      <td>1621852</td>\n",
       "      <td>...</td>\n",
       "      <td>303312</td>\n",
       "      <td>0</td>\n",
       "      <td>926597</td>\n",
       "      <td>383549</td>\n",
       "      <td>838042</td>\n",
       "      <td>904849</td>\n",
       "      <td>897207</td>\n",
       "      <td>1253616</td>\n",
       "      <td>1465624</td>\n",
       "      <td>1423967</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2346302</td>\n",
       "      <td>2343851</td>\n",
       "      <td>3533141</td>\n",
       "      <td>3292237</td>\n",
       "      <td>2989424</td>\n",
       "      <td>2086876</td>\n",
       "      <td>2529565</td>\n",
       "      <td>2094228</td>\n",
       "      <td>1904381</td>\n",
       "      <td>1720463</td>\n",
       "      <td>...</td>\n",
       "      <td>1224927</td>\n",
       "      <td>926597</td>\n",
       "      <td>0</td>\n",
       "      <td>547054</td>\n",
       "      <td>775821</td>\n",
       "      <td>1192261</td>\n",
       "      <td>883946</td>\n",
       "      <td>1208103</td>\n",
       "      <td>758110</td>\n",
       "      <td>744929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2086066</td>\n",
       "      <td>2083615</td>\n",
       "      <td>3272905</td>\n",
       "      <td>3032001</td>\n",
       "      <td>2729188</td>\n",
       "      <td>1826211</td>\n",
       "      <td>2046276</td>\n",
       "      <td>1671386</td>\n",
       "      <td>1816148</td>\n",
       "      <td>1669561</td>\n",
       "      <td>...</td>\n",
       "      <td>660608</td>\n",
       "      <td>383549</td>\n",
       "      <td>547054</td>\n",
       "      <td>0</td>\n",
       "      <td>519303</td>\n",
       "      <td>1049418</td>\n",
       "      <td>807527</td>\n",
       "      <td>1160208</td>\n",
       "      <td>1083915</td>\n",
       "      <td>1042258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2587861</td>\n",
       "      <td>2585410</td>\n",
       "      <td>3774700</td>\n",
       "      <td>3533796</td>\n",
       "      <td>3230983</td>\n",
       "      <td>2260044</td>\n",
       "      <td>2436660</td>\n",
       "      <td>2079625</td>\n",
       "      <td>2317943</td>\n",
       "      <td>2183377</td>\n",
       "      <td>...</td>\n",
       "      <td>856259</td>\n",
       "      <td>838042</td>\n",
       "      <td>775821</td>\n",
       "      <td>519303</td>\n",
       "      <td>0</td>\n",
       "      <td>1553480</td>\n",
       "      <td>1311589</td>\n",
       "      <td>1667998</td>\n",
       "      <td>1502196</td>\n",
       "      <td>1441495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1161356</td>\n",
       "      <td>1158905</td>\n",
       "      <td>2348195</td>\n",
       "      <td>2107291</td>\n",
       "      <td>1804478</td>\n",
       "      <td>909276</td>\n",
       "      <td>1393252</td>\n",
       "      <td>957915</td>\n",
       "      <td>835747</td>\n",
       "      <td>755471</td>\n",
       "      <td>...</td>\n",
       "      <td>1137121</td>\n",
       "      <td>904849</td>\n",
       "      <td>1192261</td>\n",
       "      <td>1049418</td>\n",
       "      <td>1553480</td>\n",
       "      <td>0</td>\n",
       "      <td>325491</td>\n",
       "      <td>355077</td>\n",
       "      <td>1081896</td>\n",
       "      <td>1121088</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1477547</td>\n",
       "      <td>1475096</td>\n",
       "      <td>2664386</td>\n",
       "      <td>2423482</td>\n",
       "      <td>2120669</td>\n",
       "      <td>1218121</td>\n",
       "      <td>1681446</td>\n",
       "      <td>1246109</td>\n",
       "      <td>1081808</td>\n",
       "      <td>889395</td>\n",
       "      <td>...</td>\n",
       "      <td>1184770</td>\n",
       "      <td>897207</td>\n",
       "      <td>883946</td>\n",
       "      <td>807527</td>\n",
       "      <td>1311589</td>\n",
       "      <td>325491</td>\n",
       "      <td>0</td>\n",
       "      <td>354217</td>\n",
       "      <td>817897</td>\n",
       "      <td>822315</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>1431143</td>\n",
       "      <td>1358857</td>\n",
       "      <td>2534550</td>\n",
       "      <td>2293646</td>\n",
       "      <td>1990833</td>\n",
       "      <td>1243653</td>\n",
       "      <td>1738006</td>\n",
       "      <td>1302669</td>\n",
       "      <td>700706</td>\n",
       "      <td>515972</td>\n",
       "      <td>...</td>\n",
       "      <td>1458130</td>\n",
       "      <td>1253616</td>\n",
       "      <td>1208103</td>\n",
       "      <td>1160208</td>\n",
       "      <td>1667998</td>\n",
       "      <td>355077</td>\n",
       "      <td>354217</td>\n",
       "      <td>0</td>\n",
       "      <td>858848</td>\n",
       "      <td>929000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1431143</td>\n",
       "      <td>1358857</td>\n",
       "      <td>2534550</td>\n",
       "      <td>2293646</td>\n",
       "      <td>1990833</td>\n",
       "      <td>1243653</td>\n",
       "      <td>1738006</td>\n",
       "      <td>1302669</td>\n",
       "      <td>700706</td>\n",
       "      <td>515972</td>\n",
       "      <td>...</td>\n",
       "      <td>1458130</td>\n",
       "      <td>1253616</td>\n",
       "      <td>1208103</td>\n",
       "      <td>1160208</td>\n",
       "      <td>1667998</td>\n",
       "      <td>355077</td>\n",
       "      <td>354217</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>929000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2273144</td>\n",
       "      <td>2270693</td>\n",
       "      <td>3459983</td>\n",
       "      <td>3219079</td>\n",
       "      <td>2916266</td>\n",
       "      <td>2013718</td>\n",
       "      <td>2463568</td>\n",
       "      <td>2028231</td>\n",
       "      <td>1563775</td>\n",
       "      <td>1379857</td>\n",
       "      <td>...</td>\n",
       "      <td>1719942</td>\n",
       "      <td>1423967</td>\n",
       "      <td>744929</td>\n",
       "      <td>1042258</td>\n",
       "      <td>1441495</td>\n",
       "      <td>1121088</td>\n",
       "      <td>822315</td>\n",
       "      <td>929000</td>\n",
       "      <td>929000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>33 rows × 33 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         北京       天津      哈尔滨       长春       沈阳      石家庄     呼和浩特       太原  \\\n",
       "0         0   122476  1229869   987941   682963   294125   491658   487353   \n",
       "1    122476        0  1201742   959814   654836   314982   614846   508210   \n",
       "2   1229869  1201742        0   244488   551085  1493810  1684809  1687038   \n",
       "3    987941   959814   244488        0   310181  1252906  1431315  1446134   \n",
       "4    682963   654836   551085   310181        0   950093  1171538  1143321   \n",
       "5    294125   314982  1493810  1252906   950093        0   594851   214615   \n",
       "6    491658   614846  1684809  1431315  1171538   594851        0   443246   \n",
       "7    487353   508210  1687038  1446134  1143321   214615   443246        0   \n",
       "8   1210971  1093989  2269863  2028959  1726146  1170170  1703117  1365196   \n",
       "9   1277042  1217026  2392900  2151996  1849183  1180721  1724699  1357544   \n",
       "10  1867253  1814186  2989879  2748975  2446162  1687844  2273946  1819081   \n",
       "11  2114801  2112350  3301640  3060736  2757923  1855375  2305225  1869888   \n",
       "12  2627876  2625425  3814715  3573811  3270998  2368450  2811139  2375802   \n",
       "13  1023736   956379  2132072  1891168  1588355   888447  1474549  1019684   \n",
       "14   690797   711654  1890482  1649578  1346765   423416   882350   447013   \n",
       "15  1002497   935319  2111193  1870289  1567476   906176  1450154  1082999   \n",
       "16   409437   342726  1518600  1277696   974883   334696   871374   535847   \n",
       "17  1436024  1483762  2634602  2393698  2090885  1198067  1122610   992238   \n",
       "18  1193164  1146196  2386315  2132821  1753319   927565   714173   721736   \n",
       "19  1193164  1146196  2386315  2132821  1753319   927565   714173   721736   \n",
       "20  1074438  1095295  2274123  2033219  1730406   791258   969574   610839   \n",
       "21  3548859  3596597  4747437  4506533  4203720  3310902  3235445  3105073   \n",
       "22  2779905  2903093  3973056  3719562  3459785  2887289  2300914  2737040   \n",
       "23  1835076  1855933  3034761  2793857  2491044  1551896  1728512  1371477   \n",
       "24  1753571  1774428  2953256  2712352  2409539  1470391  1664862  1289972   \n",
       "25  2346302  2343851  3533141  3292237  2989424  2086876  2529565  2094228   \n",
       "26  2086066  2083615  3272905  3032001  2729188  1826211  2046276  1671386   \n",
       "27  2587861  2585410  3774700  3533796  3230983  2260044  2436660  2079625   \n",
       "28  1161356  1158905  2348195  2107291  1804478   909276  1393252   957915   \n",
       "29  1477547  1475096  2664386  2423482  2120669  1218121  1681446  1246109   \n",
       "30  1431143  1358857  2534550  2293646  1990833  1243653  1738006  1302669   \n",
       "31  1431143  1358857  2534550  2293646  1990833  1243653  1738006  1302669   \n",
       "32  2273144  2270693  3459983  3219079  2916266  2013718  2463568  2028231   \n",
       "\n",
       "         上海       杭州  ...       成都       重庆       南宁       贵阳       昆明  \\\n",
       "0   1210971  1277042  ...  1835076  1753571  2346302  2086066  2587861   \n",
       "1   1093989  1217026  ...  1855933  1774428  2343851  2083615  2585410   \n",
       "2   2269863  2392900  ...  3034761  2953256  3533141  3272905  3774700   \n",
       "3   2028959  2151996  ...  2793857  2712352  3292237  3032001  3533796   \n",
       "4   1726146  1849183  ...  2491044  2409539  2989424  2729188  3230983   \n",
       "5   1170170  1180721  ...  1551896  1470391  2086876  1826211  2260044   \n",
       "6   1703117  1724699  ...  1728512  1664862  2529565  2046276  2436660   \n",
       "7   1365196  1357544  ...  1371477  1289972  2094228  1671386  2079625   \n",
       "8         0   179942  ...  1956341  1702128  1904381  1816148  2317943   \n",
       "9    179942        0  ...  1885005  1621852  1720463  1669561  2183377   \n",
       "10   766205   623237  ...  1994720  1743410  1444027  1567408  2082503   \n",
       "11  1430436  1246518  ...  1581801  1293041   566800   909989  1341800   \n",
       "12  2031457  1847539  ...  1700876  1405482   485498  1033615  1216344   \n",
       "13   460323   407754  ...  1512751  1244120  1599512  1438117  1939912   \n",
       "14   939925   927970  ...  1236106  1154601  1690310  1429645  1931440   \n",
       "15   300126   281354  ...  1665559  1396928  1751162  1590925  2092720   \n",
       "16   827062   877380  ...  1661261  1550091  2046442  1797508  2299303   \n",
       "17  1997565  1944996  ...   975617  1087724  2017406  1481155  1790871   \n",
       "18  1975560  1957012  ...  1286130  1253297  2182979  1646728  1994278   \n",
       "19  1975560  1957012  ...  1286130  1253297  2182979  1646728  1994278   \n",
       "20  1371668  1319099  ...   775889   690978  1608643  1072392  1484037   \n",
       "21  4128003  4075434  ...  1992559  2272211  2962662  2545739  2188273   \n",
       "22  3914510  3861941  ...  2879752  2991859  3921541  3385290  3695006   \n",
       "23  1956341  1885005  ...        0   303312  1224927   660608   856259   \n",
       "24  1702128  1621852  ...   303312        0   926597   383549   838042   \n",
       "25  1904381  1720463  ...  1224927   926597        0   547054   775821   \n",
       "26  1816148  1669561  ...   660608   383549   547054        0   519303   \n",
       "27  2317943  2183377  ...   856259   838042   775821   519303        0   \n",
       "28   835747   755471  ...  1137121   904849  1192261  1049418  1553480   \n",
       "29  1081808   889395  ...  1184770   897207   883946   807527  1311589   \n",
       "30   700706   515972  ...  1458130  1253616  1208103  1160208  1667998   \n",
       "31   700706   515972  ...  1458130  1253616  1208103  1160208  1667998   \n",
       "32  1563775  1379857  ...  1719942  1423967   744929  1042258  1441495   \n",
       "\n",
       "         武汉       长沙       南昌       香港       澳门  \n",
       "0   1161356  1477547  1431143  2203897  2273144  \n",
       "1   1158905  1475096  1358857  2201446  2270693  \n",
       "2   2348195  2664386  2534550  3390736  3459983  \n",
       "3   2107291  2423482  2293646  3149832  3219079  \n",
       "4   1804478  2120669  1990833  2847019  2916266  \n",
       "5    909276  1218121  1243653  1974526  2013718  \n",
       "6   1393252  1681446  1738006  2458502  2463568  \n",
       "7    957915  1246109  1302669  2023165  2028231  \n",
       "8    835747  1081808   700706  1493623  1563775  \n",
       "9    755471   889395   515972  1309705  1379857  \n",
       "10   891724   845608   546197   848710   948348  \n",
       "11   963961   665817   783023   168978   160972  \n",
       "12  1484027  1175712  1345540   700104   596171  \n",
       "13   395042   730757   444491  1283593  1353745  \n",
       "14   512710   821555   857464  1577960  1617152  \n",
       "15   547850   882407   596693  1433969  1504121  \n",
       "16   858207  1177687  1064743  1900748  1973284  \n",
       "17  1367382  1627168  1727418  2404872  2409290  \n",
       "18  1441833  1701619  1801869  2479323  2483741  \n",
       "19  1441833  1701619  1801869  2479323  2483741  \n",
       "20   740806  1000592  1100842  1778296  1782714  \n",
       "21  3502041  3157022  3433608  3630295  3627977  \n",
       "22  3280138  3539924  3640174  4317628  4322046  \n",
       "23  1137121  1184770  1458130  1761599  1719942  \n",
       "24   904849   897207  1253616  1465624  1423967  \n",
       "25  1192261   883946  1208103   758110   744929  \n",
       "26  1049418   807527  1160208  1083915  1042258  \n",
       "27  1553480  1311589  1667998  1502196  1441495  \n",
       "28        0   325491   355077  1081896  1121088  \n",
       "29   325491        0   354217   817897   822315  \n",
       "30   355077   354217        0   858848   929000  \n",
       "31   355077   354217        1        0   929000  \n",
       "32  1121088   822315   929000   929000        0  \n",
       "\n",
       "[33 rows x 33 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_city = data.copy()\n",
    "df_city = df_city.iloc[:,1:]\n",
    "df_city"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-06T08:50:12.579012Z",
     "start_time": "2020-12-06T08:50:12.569011Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['北京', '天津', '哈尔滨', '长春', '沈阳', '石家庄', '呼和浩特', '太原', '上海', '杭州', '福州',\n",
       "       '广州', '海口', '合肥', '郑州', '南京', '济南', '兰州', '银川', '西宁', '西安', '拉萨',\n",
       "       '乌鲁木齐', '成都', '重庆', '南宁', '贵阳', '昆明', '武汉', '长沙', '南昌', '香港', '澳门'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_names= df_city.columns\n",
    "city_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-06T08:52:12.826889Z",
     "start_time": "2020-12-06T08:52:12.817889Z"
    }
   },
   "outputs": [],
   "source": [
    "# 设置数据\n",
    "def create_data_model(distance_matrix, num_vehicles, depot):\n",
    "    data = {}\n",
    "    data['distance_matrix'] = distance_matrix /1000\n",
    "    data['num_vehicles'] = num_vehicles\n",
    "    data['depot'] = depot\n",
    "\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-06T08:50:12.607013Z",
     "start_time": "2020-12-06T08:50:12.595013Z"
    }
   },
   "outputs": [],
   "source": [
    "def print_solution(manager, routing, solution):\n",
    "    #记录每辆车的里程\n",
    "    distance_list = []\n",
    "    #记录每辆车的路径规划\n",
    "    route_list = []\n",
    "    \n",
    "    #遍历每辆车\n",
    "    for vehicle_id in range(data['num_vehicles']):\n",
    "        #针对vehicle_id辆车进行路径规划\n",
    "        route=[]\n",
    "        \n",
    "        #初始化距离为0\n",
    "        route_distance = 0\n",
    "        \n",
    "        #start后面是vehicle_id辆车\n",
    "        #从vihicle_id的其实节点出发\n",
    "        index = routing.Start(vehicle_id)\n",
    "        \n",
    "        #plan_output = '第{}辆车的路径规划:\\n'.format(vehicle_id)\n",
    "        \n",
    "        #判断这辆车的路径是否结束\n",
    "        while not routing.IsEnd(index):\n",
    "            #将manager中的index转换为distance matrix中的index\n",
    "            index_show = manager.IndexToNode(index)\n",
    "            \n",
    "            #添加到route中\n",
    "            route.append(index_show)\n",
    "            previous_index = index\n",
    "            \n",
    "            #走到下一个节点\n",
    "            index = solution.Value(routing.NextVar(index))\n",
    "            \n",
    "            #针对vehicle_id，统计从previous_index到index的距离\n",
    "            route_distance += routing.GetArcCostForVehicle(\n",
    "                previous_index, index, vehicle_id)\n",
    "            \n",
    "        \n",
    "        distance_list.append(route_distance)\n",
    "        route_list.append(route)\n",
    "    \n",
    "    return distance_list, route_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-06T09:13:40.126067Z",
     "start_time": "2020-12-06T09:13:37.935942Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第0辆车的路径规划: 北京->太原->银川->西宁->兰州->乌鲁木齐->呼和浩特\n",
      "第0辆车的总行驶里程: 6341公里\n",
      "\n",
      "第1辆车的路径规划: 北京->拉萨\n",
      "第1辆车的总行驶里程: 7096公里\n",
      "\n",
      "第2辆车的路径规划: 北京->石家庄->西安->成都->重庆->贵阳->昆明->南宁->海口->澳门->广州->香港->南昌->合肥->济南\n",
      "第2辆车的总行驶里程: 6749公里\n",
      "\n",
      "第3辆车的路径规划: 北京->郑州->武汉->长沙->福州->杭州->上海->南京->天津->沈阳->哈尔滨->长春\n",
      "第3辆车的总行驶里程: 6845公里\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from __future__ import print_function\n",
    "from ortools.constraint_solver import routing_enums_pb2\n",
    "from ortools.constraint_solver import pywrapcp\n",
    "# Step1:初始化数据，得到3个参数的字典\n",
    "data = create_data_model(df_city.to_numpy(), 4, 0)\n",
    "\n",
    "# Step2:创建路线管理，tsp_size（城市数量）, num_vehicles（车的数量）, depot（原点）\n",
    "manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),\n",
    "                                       data['num_vehicles'], data['depot'])\n",
    "\n",
    "# Step3:创建 Routing Model.\n",
    "routing = pywrapcp.RoutingModel(manager)\n",
    "\n",
    "# Step4:计算两点之间的距离,输入的是manager中的两个节点index，输出的是matrix中的两个城市的距离\n",
    "def distance_callback(from_index, to_index):\n",
    "    # Convert from routing variable Index to distance matrix NodeIndex.\n",
    "    from_node = manager.IndexToNode(from_index)\n",
    "    to_node = manager.IndexToNode(to_index)\n",
    "    return data['distance_matrix'][from_node][to_node]\n",
    "\n",
    "transit_callback_index = routing.RegisterTransitCallback(distance_callback)\n",
    "\n",
    "# Define cost of each arc.\n",
    "routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)\n",
    "\n",
    "# Step5:添加距离约束\n",
    "dimension_name = 'Distance'\n",
    "routing.AddDimension(\n",
    "    transit_callback_index,\n",
    "    0,  # no slack\n",
    "    10000,  # 车辆最大行驶距离\n",
    "    True,  # start cumul to zero\n",
    "    dimension_name)\n",
    "distance_dimension = routing.GetDimensionOrDie(dimension_name)\n",
    "# 尽量减少车辆之间的最大距离\n",
    "distance_dimension.SetGlobalSpanCostCoefficient(100)\n",
    "\n",
    "\n",
    "# Step6:设置参数策略\n",
    "search_parameters = pywrapcp.DefaultRoutingSearchParameters()\n",
    "\n",
    "#定义最有化问题的目标\n",
    "search_parameters.first_solution_strategy = (\n",
    "    routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)\n",
    "\n",
    "# Step7:求解路径规划\n",
    "solution = routing.SolveWithParameters(search_parameters)\n",
    "\n",
    "#print(solution)\n",
    "# Step8:输出结果\n",
    "if solution:\n",
    "    distance_list, route_list = print_solution(manager, routing, solution)\n",
    "    #打印路径规划的数组\n",
    "#     print(distance_list)\n",
    "#     print(route_list)\n",
    "    for vehicle_id in range(data['num_vehicles']):\n",
    "        #城市编号\n",
    "        #vehicles_string = '->'.join([str(i) for i in route_list[vehicle_id]])\n",
    "        #城市名\n",
    "        vehicles_string = '->'.join([city_names[i] for i in route_list[vehicle_id]])\n",
    "        plan_output = '第{}辆车的路径规划: {}'.format(vehicle_id,vehicles_string)\n",
    "        print(plan_output)\n",
    "\n",
    "        print('第{}辆车的总行驶里程: {}公里\\n'.format(vehicle_id, distance_list[vehicle_id]))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
